package MOLE.Bill;

import MOLE.*;

/** 
 BillFormatCheck ��ժҪ˵����
 1��������ע  -|_|_|_|456
 ������"@"�ָ�   444|4|4|5454|@54564@fj@56465465
 1�Ų�Ʊ��������...
 
*/
public class BillFormatCheck
{
	private static String span0 = "-"; //��Ʊ��λ��
	private static String span1 = "|"; //��Ʊλ������
	private static String span2 = "@"; //��Ʊע������


	public BillFormatCheck(int playid, String number)
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}

	//�淨��ID�Ƿ���Ч
	public static boolean CheckPlayIdIsExist(int playid)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String s = BillResx.BillType;
		String[] ss = s.split("[,]", -1);
		String r = "";
		for (int i = 0;i < ss.length;i++)
		{
			if (ss[i].trim().equals(String.valueOf(playid)))
			{
				return true;
			}

		}
		return false;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion

	}


	////��Ʊ��Ͷע��ʽ�Ƿ���Ч
	public static boolean BillNumberIsOkByPlayid(int playid, String inputData)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region

		if (playid == BillResx.Playid_SingleSelectFiveStar)
		{
			return IsRegexOk(1, 5, inputData);
		}
		 if (playid == BillResx.Playid_SingleSelectThreeStar)
		 {
			return IsRegexOk(1, 3, inputData);
		 }
		 if (playid == BillResx.Playid_SingleSelectTwoStar)
		 {
			return IsRegexOk(1, 2, inputData);
		 }
		 if (playid == BillResx.Playid_SingleSelectOneStar)
		 {
			return IsRegexOk(1, 1, inputData);
		 }


		if (playid == BillResx.Playid_MultiSelectFiveStar)
		{
			return IsRegexOk(2, 5, inputData);
		}
		 if (playid == BillResx.Playid_MultiSelectThreeStar)
		 {
			return IsRegexOk(2, 3, inputData);
		 }
		 if (playid == BillResx.Playid_MultiSelectTwoStar)
		 {
			return IsRegexOk(2, 2, inputData);
		 }
		 if (playid == BillResx.Playid_MultiSelectOneStar)
		 {
			return IsRegexOk(2, 1, inputData);
		 }


		//heazh
		if (playid == BillResx.Playid_HeazhThreeStar)
		{
			return IsRegexOk(3, 3, inputData);
		}
		 if (playid == BillResx.Playid_HeazhTwoStar)
		 {
			return IsRegexOk(3, 2, inputData);
		 }

		return false;




//			switch(playid)
//			{
//				case 50120001: //ʱʱ�ʵ�ѡ����
//					return IsRegexOk(1,5,inputData);
//				case 50120002:  //ʱʱ�ʵ�ѡ3��  //NO 4 START //4 IS NOT GOOD FOR
//					return IsRegexOk(1,3,inputData);
//				case 50120003:
//					return IsRegexOk(1,2,inputData);
//				case 50120004:
//					return IsRegexOk(1,1,inputData);
//
//					
//										//ZUHA
//					case 50120011: //ʱʱ���������
//						return IsRegexOk(2,5,inputData);
//					case 50120012:  //ʱʱ�����3��  //NO 4 START //4 IS NOT GOOD FOR
//						return IsRegexOk(2,3,inputData);					 
//					case 50120013:
//						return IsRegexOk(2,2,inputData);
//					case 50120014:
//						return IsRegexOk(2,1,inputData);
//							
//					
//						//HEZHI
//					case 50120005:
//					 	  return IsRegexOk(3,3,inputData);
// 					case 50120006:
//							return IsRegexOk(3,2,inputData);
//					default:
//						return false;
//				}
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion

	}

	//��ƱͶע�ĸ�ʽ�Ƿ���Ч
	public static boolean IsRegexOk(int selectType, int start, String inputData)
	{
		Match m = (new Regex(GetRegexMultiStr(selectType, start))).Match(inputData);
		return m.Success;
	}







	//�õ�����Ͷע(������ѡ�����,��ֵ)��������Ʊ�ĸ�ʽ
	private static String GetRegexMultiStr(int selectType, int Statr)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String s = GetSingleTyaor(selectType, Statr);
		s = tangible.DotNetToJavaStringHelper.trim(s, '^');
		s = tangible.DotNetToJavaStringHelper.trim(s, '$');

		// string r="(@para)|((@para@)+@para)";
		String r = "(@para@span)*@para";
		r = r.replace("@span",span2);
		r = r.replace("@para",s);
		r = "^" + r + "$";
		return r;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	//�õ�����Ͷע(������ѡ�����,��ֵ)��������Ʊ�ĸ�ʽ
	private static String GetSingleTyaor(int TeuzhuType, int star)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		if (TeuzhuType == BillResx.TeuzhuType_SingleSelect)
		{
			return GetRegexStr(BillResx.TeuzhuType_SingleSelect, star);
		}
		if (TeuzhuType == BillResx.TeuzhuType_MultiSelect)
		{
			return GetRegexStr(BillResx.TeuzhuType_MultiSelect, star);
		}
		if (TeuzhuType == BillResx.TeuzhuType_Heazh)
		{
			return GeHeazhSingleTyaor(star);
		}
		else
		{
			return "TEUZHU_TYPE IS ERR!! ONLY 1,2,3";
		}
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	//�õ���׼Ͷע(������ѡ�����)��ע��Ʊ�ĸ�ʽ
	private static String GetRegexStr(int selectType, int Statr)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String span = "";
		if (selectType == 1) //single
		{
		}
		else
		{
			span = "+";
		}
		String s = "";
		s = "^";
		int j = Statr;
		for (int i = 0;i < 5 - j;i++)
		{
			s = s + "[" + span0 + "][\\" + span1 + "]";
		}
		for (int i = 0;i < j;i++)
		{
			if (i + 1 < j)
			{
				s = s + "[0-9]" + span + "[\\" + span1 + "]";
			}
			else
			{
				s = s + "[0-9]" + span;
			}
		}
		s = s + "$";
		return s;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}

	//�ȵ���ֵ������
	private static String GeHeazhSingleTyaor(int Statr)
	{
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		if (Statr == 2) //Two
		{
			return "^(\\d|(1[0-8]))$";
		}
		else //Three
		{
			return "^(\\d|(1\\d)|(2[0-7]))$";
		}
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	}



}